<div class="container" id="user-seen">
    <div class="header layui-bg-black">
        <div class="header title">看过的电影</div>
    </div>
    <div id="user_seen_movies">

    </div>

    <script id="movie_seen_tpl" type="text/html">
        <ul>
            {{# layui.each(d, function(index, item){ }}
            <li style="padding: 10px 0 0 0">
                <a class="movie-item-a" href="/movie.html?movie={{ item.id }}">
                    <div class="movie-item">
                        <div class="layui-col-xs3 movie-item-img">
                            <img src="{{ item.cover }}">
                        </div>
                        <div class="layui-col-xs7">
                            <div class="movie-item-title"><span>{{item.name}}</span>
                                {{# if(item.type != ""){ }}
                                <span class="layui-badge layui-bg-black circle">{{item.type}}</span>
                                {{# } }}
                            </div>
                            <div>
                                <span>观众评分：</span>
                                <span style="color: orangered">{{item.score}}</span>
                            </div>
                            <div>
                                <span>导演：{{item.director}}</span>
                            </div>
                            <div>
                                <span>主演：{{item.players}}</span>
                            </div>
                            <div>
                                <span>标签：</span>
                                {{# layui.each(item.tags, function(i, o){ }}
                                <span class="layui-badge layui-bg-gray">{{o}}</span>
                                {{# }); }}
                            </div>
                        </div>
                        <div class="layui-col-xs2 movie-item-buy">
                            <button data-href="/comment.html?movie={{ item.id }}"
                                    class="layui-btn layui-bg-orange user_seen_comment">评论
                            </button>
                        </div>
                    </div>
                </a>
                <hr>
            </li>
            {{# }); }}
            {{# if(d.length === 0){ }}
            {{# } }}
        </ul>
    </script>
</div>
<script>
    flow.load({
        elem: '#user_seen_movies',
        isAuto: true,
        done: function (page, next) {
            $.get('/api/user/seen?page=' + page, function (res) {
                if (res.code === 0) {
                    let movie_comment_tpl = movie_seen_tpl.innerHTML;
                    laytpl(movie_comment_tpl).render(resp.data, function (html) {
                        next(html, page < 1);
                    });
                }
            });
        }
    });
    $('.user_seen_comment').unbind('click').click(function (e) {
        let href = $(this).data('href');
        Router.navigate(href);
        Router.check();
        return false;
    })
</script>